import { postRequest, postRequest2 } from '@/utils/api'
import { param } from '.'

// 上传添加：/gv-kube/resource/cluster/upload
// 	String clusterZhname、String clusterUrl、String clusterDescription
// 	file

const $clusterManageApi = {
  // 分页获取所有集群信息
  pageGetCluster: param => {
    return postRequest('/gv-kube/resource/cluster/page', param)
  },
  // 搜索过滤
  filterCluster: param => {
    return postRequest('/gv-kube/resource/cluster/page', param)
  },
  // 删除
  delectCluster: param => {
    return postRequest('/gv-kube/resource/cluster/delete', param)
  },
  // 上传添加
  uploadAddCluster: param => {
    // return postRequest(
    //   `/gv-kube/resource/cluster/upload?clusterZhname=${param.clusterZhname}&clusterUrl=${param.clusterUrl}&clusterDescription=${param.clusterDescription}&file=${param.file}`
    // )
    // return postRequest2('/gv-kube/resource/cluster/upload', param)
    return postRequest('/gv-kube/resource/cluster/upload', param)
  },
  // 查看细节
  getClusterDetail: param => {
    return postRequest(`/gv-kube/resource/cluster/detail?id=${param}`)
  },
  // 更新集群信息
  updateClusterInfo: param => {
    return postRequest('/gv-kube/resource/cluster/update/info', param)
  },
  // 更新集群信息
  connectClusterbyId: param => {
    return postRequest(`/gv-kube/resource/cluster/connect?id=${param}`, null)
  },
  // 更新集群信息
  getClusterBasicinformationByid: param => {
    return postRequest(
      `/gv-kube/resource/cluster/basic/information?id=${param}`,
      null
    )
  },
  // 退出登录
  logOut: param => {
    return postRequest(`/gv-kube/user/layout?token=${param}`)
  },
  // 首页获取资源信息
  getAllResourceInfo: () => {
    return postRequest('/gv-kube/resource/cluster/get/all')
  },

  // 集群总览页面获取数据
  getOverviewInfo: () => {
    return postRequest('/gv-kube/resource/cluster/get/overview')
  },

  // 集群总览页面获取数据
  getClusterDashboard: (param) => {
    return postRequest(`/gv-kube/resource/cluster/get/dashboard?id=${param}`)
  },

  // 集群总览页面获取数据
  updateDashboardPort: (param) => {
    return postRequest(`/gv-kube/resource/cluster/update/dashboard/port?id=${param.clusterId}&grafanaPort=${param.port}`)
  },

  // 资源总览接口
  getTenantDashboard: param => {
    return postRequest(`/gv-kube/tenant/gvKubeTenant/get/dashboard?id=${param}`);
  },

 // 分区管理页面获取集群列表
  getPartClusterList: param => {
    return postRequest('/gv-kube/resource/cluster/partition/page', param)
  },
  //分区页面根据集群信息获取集群节点信息
  getPartClusterNode: param => {
    return postRequest(`/gv-kube/resource/cluster/basic/information?id=${param}`)
  },
  //添加分区（分区名称不需要上传）
  addPartCluster: param => {
    return postRequest('/gv-kube/resource/cluster/partition/add', param)
  },
  //更新修改分区
  updatePartitionInfo: param => {
    return postRequest('/gv-kube/resource/cluster/partition/update', param)
  },
  //删除分区
  deletePartition: param => {
    return postRequest('/gv-kube/resource/cluster/partition/delete', param)
  },
  //搜索分区
  searchPartition: param => {
    return postRequest('/gv-kube/resource/cluster/partition/page', param)
  }

}

export default $clusterManageApi
